// --------------------------------------------------------------------------------------------------------------------
// <copyright file="SA1642ConstructorSummaryDocumentationMustBeginWithStandardTextBulbItem.cs" company="StyleCop for ReSharper Development Team">
//   Copyright (c) StyleCop for ReSharper Development Team. All rights reserved.
// </copyright>
// <summary>
//   Defines the SA1642ConstructorSummaryDocumentationMustBeginWithStandardTextBulbItem type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace StyleCop.For.ReSharper.BulbItems.Documentation
{
    #region Using Directives

    using JetBrains.ProjectModel;
    using JetBrains.ReSharper.Psi.CSharp.Tree;
    using JetBrains.TextControl;

    using StyleCop.For.ReSharper.BulbItems.Framework;
    using StyleCop.For.ReSharper.CodeCleanup.Rules;

    #endregion

    /// <summary>
    /// SA1642: ConstructorSummaryDocumentationMustBeginWithStandardTextBulbItem.
    /// </summary>
    public class SA1642ConstructorSummaryDocumentationMustBeginWithStandardTextBulbItem : TransactionalBulbItem
    {
        #region Public Methods

        /// <summary>
        /// Executes the SA1642ConstructorSummaryDocumentationMustBeginWithStandardTextBulbItem QuickFix.
        /// </summary>
        /// <param name="solution">
        /// The solution we belong to.
        /// </param>
        /// <param name="textControl">
        /// The control we started on.
        /// </param>
        public override void ExecuteInner(ISolution solution, ITextControl textControl)
        {
            var element = Utils.GetElementAtCaret(solution, textControl);

            if (element != null)
            {
                var constructorDeclaration = element.GetContainingElement<IConstructorDeclaration>(true);
                if (constructorDeclaration != null)
                {
                    new DocumentationRules().EnsureConstructorSummaryDocBeginsWithStandardText(constructorDeclaration);
                }
            }
        }

        #endregion
    }
}